package vy.org.app.page.subscription.dabba;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.vy.dal.dao.VyDabbaSubscriptionDAO;
import org.vy.dal.dao.VyDabbaSubscriptionDO;

import vy.org.app.common.BaseAction;
import vy.org.app.common.ModuleEnum;

public class DabbaSubscriptionAction extends BaseAction {
	public ActionForward executeAction(ActionMapping mapping, ActionForm actionForm,
			HttpServletRequest request, HttpServletResponse response) {
		try {
			DabbaForm dabbaSubscriptionForm = (DabbaForm) actionForm;

			VyDabbaSubscriptionDO dabbaSubscriptionDO = DabbaHelper.fillDabbaDO(dabbaSubscriptionForm);

			VyDabbaSubscriptionDO dabbaSubscription = (VyDabbaSubscriptionDO) VyDabbaSubscriptionDAO
					.insert(dabbaSubscriptionDO);

			if (dabbaSubscription == null) {
				return mapping.findForward("failure");
			} else {
				return mapping.findForward("success");
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		return mapping.findForward("failure");
	}

	@Override
	protected ModuleEnum getModuleId() {
		return ModuleEnum.ADD_PATRA;
	}
}
